package com.aspose.cells;

import java.util.ArrayList;

class zaql {
   private zcfx a;
   private zapt b;

   public zaql(zapt var1) {
      this.b = var1;
   }

   void a(zcfx var1) throws Exception {
      this.a = var1;
      var1.b("office:master-styles");

      for(int var2 = 0; var2 < this.b.g.size(); ++var2) {
         zapu var3 = (zapu)this.b.g.get(var2);
         this.a(var3);
      }

      var1.b();
   }

   private void a(zapu var1) throws Exception {
      this.a.b("style:master-page");
      this.a.a("style", "name", (String)null, "PageStyle_5f_" + var1.l);
      this.a.a("style", "display-name", (String)null, "PageStyle_" + var1.l);
      this.a.a("style", "page-layout-name", (String)null, "pm" + (var1.i.getIndex() + 1));
      this.b(var1);
      this.c(var1);
      this.a.b();
   }

   private void b(zapu var1) throws Exception {
      if (var1.s != null) {
         this.a.b("style:header");
         this.a("style:region-left", var1.s[0]);
         this.a("style:region-center", var1.s[1]);
         this.a("style:region-right", var1.s[2]);
         this.a.b();
         this.a.b("style:header-left");
         if (var1.p) {
            this.a("style:region-left", var1.q[0]);
            this.a("style:region-center", var1.q[1]);
            this.a("style:region-right", var1.q[2]);
         } else {
            this.a.a("style", "display", (String)null, "false");
         }

         this.a.b();
      } else {
         this.a.b("style:header");
         this.a.a("style", "display", (String)null, "false");
         this.a.b();
         this.a.b("style:header-left");
         this.a.a("style", "display", (String)null, "false");
         this.a.b();
      }

   }

   private void c(zapu var1) throws Exception {
      if (var1.t != null) {
         this.a.b("style:footer");
         this.a("style:region-left", var1.t[0]);
         this.a("style:region-center", var1.t[1]);
         this.a("style:region-right", var1.t[2]);
         this.a.b();
         this.a.b("style:footer-left");
         if (var1.p) {
            this.a("style:region-left", var1.r[0]);
            this.a("style:region-center", var1.r[1]);
            this.a("style:region-right", var1.r[2]);
         } else {
            this.a.a("style", "display", (String)null, "false");
         }

         this.a.b();
      } else {
         this.a.b("style:footer");
         this.a.a("style", "display", (String)null, "false");
         this.a.b();
         this.a.b("style:footer-left");
         this.a.a("style", "display", (String)null, "false");
         this.a.b();
      }

   }

   private void a(String var1, ArrayList var2) throws Exception {
      if (var2 != null && var2.size() != 0) {
         this.a.b(var1);
         this.a.b("text:p");

         for(int var3 = 0; var3 < var2.size(); ++var3) {
            HeaderFooterCommand var4 = (HeaderFooterCommand)var2.get(var3);
            if (var3 != 0 && var4.getType() == 6) {
               HeaderFooterCommand var5 = (HeaderFooterCommand)var2.get(var3 - 1);
               if (var5.getType() == 7) {
                  continue;
               }
            }

            this.a(var4);
         }

         this.a.b();
         this.a.b();
      }
   }

   private void a(HeaderFooterCommand var1) throws Exception {
      this.a.b("text:span");
      this.a.a("text", "style-name", (String)null, var1.getFont() == null ? "T1" : "T" + var1.getFont().j());
      label38:
      switch(var1.getType()) {
      case 0:
         String var2 = var1.getText();
         String[] var3 = com.aspose.cells.b.a.zv.d(var2, '\n');
         if (var3.length == 1) {
            this.a.a(var1.getText());
            break;
         } else {
            this.a.a(var3[0]);
            this.a.b();
            this.a.b();
            int var6 = 1;

            while(true) {
               if (var6 >= var3.length) {
                  break label38;
               }

               this.a.b("text:p");
               this.a.b("text:span");
               this.a.a("text", "style-name", (String)null, var1.getFont() == null ? "T1" : "T" + var1.getFont().j());
               this.a.a(var3[var6]);
               if (var6 < var3.length - 1) {
                  this.a.b();
                  this.a.b();
               }

               ++var6;
            }
         }
      case 1:
         this.a.b("text:page-number");
         this.a.a("1");
         this.a.b();
         break;
      case 2:
         this.a.b("text:page-count");
         this.a.a("99");
         this.a.b();
         break;
      case 3:
         DateTime var4 = DateTime.getNow();
         this.a.b("text:date");
         this.a.a("style", "date-value", (String)null, var4.b("yyyy-MM-dd"));
         this.a.a(var4.b("MM/d/yy"));
         this.a.b();
         break;
      case 4:
         DateTime var5 = DateTime.getNow();
         this.a.b("text:time");
         this.a.a(var5.b("hh:mm:ss"));
         this.a.b();
         break;
      case 5:
         this.a.b("text:sheet-name");
         this.a.a("???");
         this.a.b();
         break;
      case 6:
         this.a.b("text:file-name");
         this.a.a("text", "display", (String)null, "name-and-extension");
         this.a.a("???");
         this.a.b();
         break;
      case 7:
         this.a.b("text:file-name");
         this.a.a("text", "display", (String)null, "full");
         this.a.a("???");
         this.a.b();
      }

      this.a.b();
   }
}
